<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>登录</title>
    <script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
</head>
<body>
<form id="loginFrom">
    <script>
        function login() {
            $.ajax({
                url:'/login',
                type:'post',
                dataType:'json',
                data:$("#loginFrom").serialize(),
                success:function(result){
                    //回调函数
                    if (result.success){
                        location.href= 'http://'+window.location.host+"/index.html"
                    }else {
                        alert(result.msg);
                    }
                }
            });
        }
    </script>
    <div>
        用户名：<input type="text" name="userName"><br>
        密  码：<input type="password" name="password"><br>
    </div>
    <input type="button" value="登录" onclick="login()">
</form>
</body>
</html>